# apps/core/views.py
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from django.apps import apps

class DashboardStatsView(APIView):
    permission_classes = [IsAuthenticated]

    def get(self, request):
        stats = {
            'total_questions': apps.get_model('questions.Question').objects.count(),
            'total_users': apps.get_model('users.QBUser').objects.count(),
            'total_tags': apps.get_model('tags.Tag').objects.count(),
            'total_subjects': apps.get_model('subjects.Subject').objects.count(),
            'total_exam_papers': apps.get_model('exam_papers.ExamPaper').objects.count(),
        }
        return Response(stats)